<% 
	User user = new User();
	user = (User)session.getAttribute("user");
	if(user==null){
		response.sendRedirect("/");
	}
%>
<jsp:include page="../../layout/header.jsp" flush="true" />
<div class="container main">
<%@ page import="pizza.admin.entity.User" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Iterator" %>
<h3>Users</h3>
<table class="table table-bordered table-hover">
	<thead>
		<tr>
			<th>Id</th>
			<th>Name</th>
			<th>&nbsp;</th>
			<th width='300'><a href='/user?action=add' class='btn btn-primary'>Add new</a></th>
		</tr>
	</thead>
<% 
	Collection<User> allUsers = null;
	allUsers = (Collection<User>)request.getAttribute("allUsers");
	
	if(allUsers.size()>0){
		Iterator objectsIterator = allUsers.iterator();
		while ( objectsIterator.hasNext() ) {
			User object = (User)objectsIterator.next();
%>
	<tr>
		<td><%=object.getId().toString()%></td>
		<td><%=object.getName()+" "+object.getSurname()%></td>
		<td><a href='/user?action=edit&id=<%=object.getId().toString() %>' class='btn btn-info'>Edit</a></td>
		<td>
			<a href='javascript:;' class='btn btn-danger delete'>Delete</a>
			<div class='clearfix alert hidden-content delete-confirmation'>
				Confirm deletion
				<a href='/user?action=delete&id=<%=object.getId().toString() %>' class='btn btn-danger'>Yes</a>
				<button type="button" class="close decline-deletion">&times;</button>
			<div>
		</td>
	</tr>
<%
		}
	}else{ %>
	<tr>
		<td colspan='4'><p class="text-info">No results found.</p></td>
	</tr>
<%} %>
</table>
</div> <!-- /container -->

<jsp:include page="../../layout/footer.jsp" flush="true" />